﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace CommonRepositoryInterface.Memory
{
    public class MemoryRepositoryProvider : IRepositoryProvider
    {
        private Dictionary<Type, IList> Lists { get; set; }

        public IRepository<T> CreateRepository<T>() 
            where T : class, IDataRecord
        {
            return new MemoryRepository<T>(this, this.GetList<T>());
        }
        public IList<T> GetList<T>()
        {
            var type = typeof(T);
            if (!this.Lists.ContainsKey(type))
                this.Lists.Add(type, new List<T>());

            return (IList<T>)this.Lists[type];
        }
        public void SubmitChanges()
        {

        }
    }
}
